package com.MapJiHe;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapJiHeDeBianLi {
    public static void main(String[] args) {
        Map<String,Double>map=new HashMap<>();
        map.put("蜘蛛精",162.5);
        map.put("蜘蛛精",169.8);
        map.put("紫霞",165.8);
        map.put("至尊宝",169.5);
        map.put("牛魔王",183.6);
        System.out.println(map);
        //键找值
        //得到所有的键
        Set<String> keys = map.keySet();
        System.out.println(keys);
        for (String key : keys) {
            Double value=map.get(key);
            System.out.println(key+"=====>"+value);
        }
        System.out.println("------------------");
        //键值对
        Set<Map.Entry<String, Double>> entries = map.entrySet();
        for (Map.Entry<String, Double> entry : entries) {
            String key=entry.getKey();
            Double value=entry.getValue();
            System.out.println(key+"=====>"+value);
        }
        System.out.println("------------------");
        //Lambda方法遍历
        map.forEach((k,v)->{
            System.out.println(k+"=====>"+v);
        });

    }
}
